<<<<<<< HEAD
// pages/book/index.js
const app = getApp();
const $api = require("../../api/book").API
const $banner = require("../../api/banner").API

Page({

  /**
   * 页面的初始数据
   */
  data: {
    bannerList:[],
    indicatorDots: true,
    vertical: false,
    autoplay: false,
    interval: 2000,
    duration: 500,
    typeList:[],
    recommendList:[],
    jingxuanList:[],
  },
  onLoad(){
    var t =this
    t.getgetBooksType()
    t.getBannerByOwnerShip()
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var t = this
    t.getrecommendlist()
    t.getjingxuanlist()
  },

  
  // 跳转听书分类
  gototype(e){
    var t = this
    wx.navigateTo({
      url: '/pages/book/type/index?typekey='+e.currentTarget.dataset.key,
    })
  },
  // 跳转专辑
  gotoalbum(e){
    var t = this
    console.log(e)
    wx.navigateTo({
      url:'/pages/book/album/index?id='+e.currentTarget.dataset.id+'&type='+e.currentTarget.dataset.type,
    })
  },
  gotosearch(e){
    var t = this
    wx.navigateTo({
      url:'/pages/book/search/index?from=1'
    })
  },
  // 获取听书推荐
  getrecommendlist(){
    var t = this,
    data = {
      booksRecommendType:1,
      pageNo:1,
      member_id:wx.getStorageSync('user').member_id,
      search_type:"",
      search_order:"",
      order_type:""
    }
    $api.getrecommendlist(data).then(res=>{
      t.setData({
        recommendList:res.data
      })
    })
  },
  // 获取精选
  getjingxuanlist(){
    var t = this,
    data = {
      booksRecommendType:2,
      pageNo:1,
      member_id:wx.getStorageSync('user').member_id,
      search_type:"",
      search_order:"",
      order_type:""
    }
    $api.getrecommendlist(data).then(res=>{
      t.setData({
        jingxuanList:res.data
      })
    })
  },
  
  // 获取书籍类型
  getgetBooksType(){
    var t = this,
    data={
      dict_type:"BooksType"
    }
    var typeList = wx.getStorageSync("bookstypelist")
    if(typeList){
      t.setData({
        typeList:typeList
      })
      return false
    }
    $api.getgetBooksType(data).then(res=>{
      wx.setStorageSync('bookstypelist', res.data)
      t.setData({
        typeList:res.data
      })
      console.log(res)
    })
  },
  gotorecommendlist(){
    var t = this
    wx.navigateTo({
      url: '/pages/book/recommendlist/index',
    })
  },
  gotojingxuanlist(){
    var t = this
    wx.navigateTo({
      url: '/pages/book/jingxuanlist/index',
    })
  },
   // banner
   getBannerByOwnerShip(){
    var t = this,
    data = {
        banner_ownership:3,
    }
    $banner.getBannerByOwnerShip(data).then(res=>{
        console.log(res.data)
        t.setData({
            bannerList:res.data.detail_list,
            interval:res.data.banner_refresh
        })
    })
},
=======
// pages/book/index.js
const app = getApp();
const $api = require("../../api/book").API

Page({

  /**
   * 页面的初始数据
   */
  data: {
    bannerList:[],
    indicatorDots: true,
    vertical: false,
    autoplay: false,
    interval: 2000,
    duration: 500,
    typeList:[],
    recommendList:[],
    jingxuanList:[],
  },
  onLoad(){
    var t =this
    t.getgetBooksType()
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var t = this
    t.getrecommendlist()
    t.getjingxuanlist()
  },

  
  // 跳转听书分类
  gototype(e){
    var t = this
    wx.navigateTo({
      url: '/pages/book/type/index?typekey='+e.currentTarget.dataset.key,
    })
  },
  // 跳转专辑
  gotoalbum(e){
    var t = this
    console.log(e)
    wx.navigateTo({
      url:'/pages/book/album/index?id='+e.currentTarget.dataset.id+'&type='+e.currentTarget.dataset.type,
    })
  },
  gotosearch(e){
    var t = this
    wx.navigateTo({
      url:'/pages/book/search/index?from=1'
    })
  },
  // 获取听书推荐
  getrecommendlist(){
    var t = this,
    data = {
      booksRecommendType:1,
      pageNo:1,
      member_id:wx.getStorageSync('user').member_id,
      search_type:"",
      search_order:"",
      order_type:""
    }
    $api.getrecommendlist(data).then(res=>{
      t.setData({
        recommendList:res.data
      })
    })
  },
  // 获取精选
  getjingxuanlist(){
    var t = this,
    data = {
      booksRecommendType:2,
      pageNo:1,
      member_id:wx.getStorageSync('user').member_id,
      search_type:"",
      search_order:"",
      order_type:""
    }
    $api.getrecommendlist(data).then(res=>{
      t.setData({
        jingxuanList:res.data
      })
    })
  },
  
  // 获取书籍类型
  getgetBooksType(){
    var t = this,
    data={
      dict_type:"BooksType"
    }
    $api.getgetBooksType(data).then(res=>{
      t.setData({
        typeList:res.data
      })
      console.log(res)
    })
  },
  gotorecommendlist(){
    var t = this
    wx.navigateTo({
      url: '/pages/book/recommendlist/index',
    })
  },
  gotojingxuanlist(){
    var t = this
    wx.navigateTo({
      url: '/pages/book/jingxuanlist/index',
    })
  },
>>>>>>> 1c9ce1fdc7fcbf1a028b999eb3cd07f698a8a329
})